package cn.tedu.shoot;

import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
public class Images {
    public static BufferedImage[] hero;
    public static BufferedImage[] bees;
    public static BufferedImage[] airplane;
    public static BufferedImage[] bigairplane;
    public static BufferedImage background;
    public static BufferedImage bullet;
    public static BufferedImage gameover;
    public static BufferedImage pause;
    public static BufferedImage start;

    static {
        background =  readImage("img/background.png");
        gameover =  readImage("img/gameover.png");
        pause =  readImage("img/pause.png");
        start =  readImage("img/start.png");
        bullet = readImage("img/bullet.png");
        hero = new BufferedImage[2]; //2张图片
        hero[0] = readImage("img/hero0.png");
        hero[1] = readImage("img/hero1.png");

        airplane = new BufferedImage[5]; //5张图片
        bigairplane = new BufferedImage[5]; //5张图片
        bees = new BufferedImage[5]; //5张图片
        airplane[0] = readImage("img/airplane.png");
        bigairplane[0] = readImage("img/bigairplane.png");
        System.out.println(bigairplane[0]);
        bees[0] = readImage("img/bee.png");
        for (int i = 1; i < airplane.length; i++) { //赋值爆破图
            airplane[i] = readImage("img/bom" + i + ".png");
            bigairplane[i] = readImage("img/bom" + i + ".png");
            bees[i] = readImage("img/bom" + i + ".png");
        }
    }

    public static BufferedImage readImage(String fileName){
        try{
            BufferedImage img = ImageIO.read(FlyingObject.class.getResource(fileName)); //读取与FlyingObject同包中的图片
            return img;
        }catch(Exception e){
            e.printStackTrace();
            throw new RuntimeException();
        }
    }

    public static void main(String[] args) {
        System.out.println(Images.airplane.length); //测试代码只要用到Images类就OK
    }
}
